package com.easyedu.teacher.dao;

import com.easyedu.core.entity.po.Classroom;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lmr
 **/
@Mapper
public interface ClassroomDao {

    /**
     * 功能描述:查询空闲教室</br>
     * 数据表: classroom 教室表, open_course_time 课程开课时间表, exam_plan 考试申请
     *
     * @param year     1 开放年份
     * @param semester 2  开放学期
     * @param week     3 开课周
     * @param day      4 开课星期
     * @param lesson   5 开课节次
     * @return : java.util.List<com.easyedu.api.entity.DO.Classroom>
     **/
    @Select("select * from classroom where classroom_name NOT IN " +
            "(" +
            "    select classroom from open_course_time where open_year = #{year} AND semester = #{semester} AND " +
            "    open_week = #{week} AND open_day = #{day} AND open_lesson = #{lesson}" +
            "    UNION" +
            "    select classroom from exam_plan where school_year = #{year} AND  semester = #{semester} AND " +
            "    exam_week = #{week} AND exam_day = #{day} AND lesson = #{lesson}" +
            "    HAVING classroom IS NOT NULL)")
    List<Classroom> getUnuseClassRoom(int year, String semester, int week, int day, int lesson);
}
